home *** CD-ROM | disk | FTP | other *** search
- Path: engnews2.Eng.Sun.COM!usenet
- From: nitin@more.eng.sun.com (Nitin More [CONTRACTOR])
- Newsgroups: comp.lang.c++
- Subject: Re: locking
- Date: 10 Jan 1996 18:30:13 GMT
- Organization: SunSoft
- Message-ID: <NITIN.96Jan10103013@more.eng.sun.com>
- References: <4d0j6r$1ri@daphne.ecmwf.int>
- <30F3E9C3.15FB7483@intellektik.informatik.th-darmstadt.de>
- NNTP-Posting-Host: more.eng.sun.com
- In-reply-to: Enno Sandner's message of Wed, 10 Jan 1996 17:30:59 +0100
-
- In article <30F3E9C3.15FB7483@intellektik.informatik.th-darmstadt.de> Enno Sandner <enno@intellektik.informatik.th-darmstadt.de> writes:
-
- > From: Enno Sandner <enno@intellektik.informatik.th-darmstadt.de>
-
- [deleted]
-
- > >
- > > This seems to work, but the LockObject is only destroyed at the
- > > end of the block, locking my object for too long.
- > >
- > > main()
- > > {
- > >
- > > SharedObject<foo> fooH("lock");
- > >
- > > ... the lock is not set
- > >
- > > fooH->bar();
- > >
- > > .. the lock is set until the end.
- > > }
- > >
- > > Anyone got an idea ?
- > >
- >
- > I would say the temporary object should be destroyed directly after
- > the invocation of 'bar'.
- > As a workarround you can put the member-function call in brackets, e.g.
- >
- > { foo->bar(); }
- >
- > Enno
-
- You need to put the declaration of fooH also in the block as follows:
-
- {
- SharedObject<foo> fooH("lock");
- fooH->bar();
- .. the lock is set until the end **OF THE BLOCK**
- }
- .. fooH is destructed at the end of the block releasing the lock.
-
- -Nitin
-
-
- --
- ----------------------------------------------------------------------
- Nitin More
- SunSoft, Bldg 16 Off: (415) 786 7109
- Menlo Park, CA Fax: (415) 786 7957 e-mail: nitin@more.eng.sun.com
- ----------------------------------------------------------------------
-